define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'events/sign/index' + location.search,
                    add_url: 'events/sign/add',
                    // edit_url: 'events/sign/edit',
                    // del_url: 'events/sign/del',
                    multi_url: 'events/sign/multi',
                    import_url: 'events/sign/import',
                    table: 'events_sign',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                // fixedRightNumber: 1,
                columns: [
                    [
                        { checkbox: true },
                        { field: 'id', title: __('Id') },
                        { field: 'events.title', title: __('Events.title'), operate: 'LIKE' },
                        { field: 'name', title: __('Name'), operate: 'LIKE' },
                        { field: 'sex', title: __('Sex'), operate: 'LIKE' },
                        { field: 'mobile', title: __('Mobile'), operate: 'LIKE' },
                        { field: 'id_card', title: __('Id_card'), operate: 'LIKE' },
                        { field: 'num', title: __('Num'), operate: false },
                        { field: 'pay_status', title: __('Pay_status'), searchList: { "10": __('Pay_status 10'), "-1": __('Pay_status -1') }, formatter: Table.api.formatter.status },
                        { field: 'user.nickname', title: __('User_id') },
                        { field: 'pay_fee', title: __('Pay_fee'), operate: false },
                        { field: 'paytime', title: __('Paytime'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime },
                        { field: 'content', title: __('Content'), operate: false },
                        { field: 'canceltime', title: __('Canceltime'), operate: false, addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime },
                        { field: 'cancel', title: __('Cancel_fee'), operate: false },
                        // { field: 'createtime', title: __('Createtime'), operate: false, addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime },
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
